// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var switchChild = function(child, node_id_1, node_id_2) {
	var node_1 = document.getElementById(node_id_1);
	var node_2 = document.getElementById(node_id_2);

	if(child.parentNode == node_1) var source = node_1, target = node_2
	else var source = node_2, target = node_1;

	target.appendChild(child.cloneNode(true));
	source.removeChild(child);
};

var updateMembership = function() {
	var container = document.getElementById("member_list");
	var selected = [];
	for(var i=0; i<container.childNodes.length; i++) {
		var child = container.childNodes[i];
		if(child.nodeType != 1) continue;
		selected.push(child.innerHTML.replace(/[^a-z]/gi, ''));
	}

	zAjax.send

	_res = new zAjax().send({
		url: FULL_URL + "/repositories/" + ExtractIdFromUrl("repositories") + "/members/regenerate_membership",
		sync: true,
		method: "POST",
		data: "selected_users=" + selected,
		success: function(xhr) {
			alert(xhr.responseText);
			// succ;
		},
		failure: function(xhr) {
			// fail;
		}
	})

};
